package com.tegtech.starter.security.domain;

import java.io.Serializable;
import java.util.Collection;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import com.fasterxml.jackson.annotation.JsonIgnore;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 登录用户数据
 * @Author Jun
 * @date 2020年5月30日 下午11:05:55
 */
@Data
@NoArgsConstructor
public class LoginUser implements UserDetails, Serializable {
	
	private static final long serialVersionUID = 1L;
	
	/** 登录用户id **/
	private Long uid;
	
	/** 登录用户名称 **/
	private String username;
	
	/** 用户唯一标识 **/
	private String token;

	/** 过期时间 **/
	private Long expireTime;
	
	/** 登录用户详情 **/
	private LoginUserDetail loginUserDetail;
	
	@JsonIgnore
	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return null;
	}

	@JsonIgnore
	@Override
	public String getPassword() {
		return null;
	}

	@JsonIgnore
	@Override
	public String getUsername() {
		return username;
	}

	@JsonIgnore
	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@JsonIgnore
	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@JsonIgnore
	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@JsonIgnore
	@Override
	public boolean isEnabled() {
		return true;
	}

	public LoginUser(Long uid, String token, LoginUserDetail loginUserDetail) {
		super();
		this.uid = uid;
		this.token = token;
		this.loginUserDetail = loginUserDetail;
	}
	
}
